<!-- 用户设置 -->
<template>
	<view class="set">
		<view class="cut"></view>
		<view class="head">
			<image :src="userInfo.avatar" mode=""></image>
			<view>{{userInfo.nickname}}</view>
		</view>
		<view class="phone" @tap="phone">
			<view>
				手机号码
			</view>
			<view>
				<text v-if="userInfo.phone">{{ userInfo.phone }}</text>
				<text v-else>未绑定</text>
				<text class="cell-more yticon icon-you"></text>
			</view>
		</view>
		<view class="phone" @tap="card">
			<view>
				实名认证
			</view>
			<view>
				<text v-if="userInfo.card_id">已认证</text>
				<text v-else>未认证</text>
				<text class="cell-more yticon icon-you"></text>
			</view>
		</view>
		<!-- <view class="phone" @tap="uploadIdCard">
			<view>
				上传身份证
			</view>
			<view>
				<text v-if="userInfo.is_card">已上传</text>
				<text v-else>未上传</text>
				<text class="cell-more yticon icon-you"></text>
			</view>
		</view> -->
		<view class="phone" @tap="bank">
			<view>
				银行卡管理
			</view>
			<view>
				<text class="cell-more yticon icon-you"></text>
			</view>
		</view>
		<view class="phone" @tap="payPassword">
			<view>
				操作密码
			</view>
			<view>
				<text v-if="userInfo.withdraw_pass">已设置</text>
				<text v-else>未设置</text>
				<text class="cell-more yticon icon-you"></text>
			</view>
		</view>
		
		<view class="loginOut" @tap="loginOut">
			退出登录
		</view>
	</view>
</template>

<script>
	import {logout} from "@/api/public.js"
	import { getUserInfo } from '@/api/user.js'
	export default {
		data() {
			return {
				userInfo: {},
			};
		},
		onShow() {
			getUserInfo().then(res => {
				this.userInfo = res.data;
				uni.setStorageSync('userInfo', res.data);
			})
			// this.userInfo = uni.getStorageSync('userInfo')
		},
		methods: {
			// 手机号
			phone() {
				if (this.userInfo.phone) {
					uni.navigateTo({
						url: "/pages/center/accountSet/phone/phone"
					});
				} else {
					uni.navigateTo({
						url: "/pages/center/accountSet/phone/addPhone"
					});
				}
			},
			// 身份证
			card() {
				if (this.userInfo.card_id) {
					uni.navigateTo({
						url: "/pages/center/accountSet/certification/success"
					})
				} else {
					uni.navigateTo({
						url: "/pages/center/accountSet/certification/certification"
					})
				}
			},
			// 操作密码
			payPassword() {
				if (this.userInfo.withdraw_pass) {
					uni.navigateTo({
						url: "/pages/center/accountSet/payPassword/pwdready"
					})
				} else {
					uni.navigateTo({
						url: "/pages/center/accountSet/payPassword/payPassword"
					})
				}
			},
			// 银行卡管理
			bank() {
				uni.navigateTo({
					url: "/pages/center/accountSet/bank/bankList"
				});
			},
			// uploadIdCard(){
			// 	if(this.userInfo.card_id){
			// 		return uni.navigateTo({
			// 			url: "/pages/center/accountSet/idCard/idCard"
			// 		});
			// 	}
			// 	uni.showModal({
			// 		content: "您还未实名认证，是否去认证",
			// 		confirmText: "去认证",
			// 		cancelText: "取消",
			// 		confirmColor: "#57BE6A",
			// 		success(res) {
			// 			if (res.confirm) {
			// 				uni.navigateTo({
			// 					url: "/pages/center/accountSet/certification/certification?backurl=true"
			// 				})
			// 			}
			// 		}
			// 	})
				
			// },
			loginOut() {
				uni.showLoading({
					mask:true
				})
				logout({}).then(res => {
					uni.removeStorageSync('Authori-zation')
					uni.removeStorageSync('userInfo')
					setTimeout(() => {
						uni.showToast({
							title: "退出成功",
						});
					}, 500);
					uni.reLaunch({
						url: "/pages/index/index"
					})
				})
			},
			goAbout() {
				uni.navigateTo({
					url: '/pages/center/set/about/about'
				})
			}
		}
	};
</script>

<style lang="scss" scoped>
	.set{
		padding: 0 30rpx;
	}

	.cut {
		width: 750rpx;
		margin-left: -30rpx;
		height: 20rpx;
		background: rgba(238, 238, 238, 1);
	}

	.head {
		text-align: center;
		padding: 83rpx 0;
		image{
			width: 120rpx;
			height: 120rpx;
			border-radius: 60rpx;
		}
		view{
			margin-top: 20rpx;
			font-size:24rpx;
		}
	}

	.phone {
		width: 690rpx;
		height: 42rpx;
		padding: 32rpx 0;
		background: rgba(255, 255, 255, 1);
		border-bottom: 1rpx solid rgba(238, 238, 238, 1);
		display: flex;
		justify-content: space-between;

		view:nth-of-type(1) {
			font-size: 30rpx;
			font-weight: 400;
			color: rgba(51, 51, 51, 1);
			line-height: 42rpx;
		}

		view:nth-of-type(2) {
			display: flex;
			line-height: 42rpx;

			text {
				margin-left: 10rpx;
				font-size: 28rpx;
				font-weight: 400;
				color: rgba(153, 153, 153, 1);
			}
		}
	}

	.loginOut {
		position: fixed;
		bottom: 60rpx;
		left: 55rpx;
		width: 640rpx;
		height: 80rpx;
		line-height: 80rpx;
		color: #fff;
		text-align: center;
		background: $theme-color;
		border-radius: 40rpx;
	}
</style>
